<?php

use think\migration\Migrator;
use think\migration\db\Column;

class SalesmanStore extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('salesman_store', ['comment' => '业务员门店关联表']);
        $table->addColumn('company_id', 'integer', ['comment' => '公司ID', 'limit' => 11, 'default' => 0])
              ->addColumn('salesman_id', 'integer', ['comment' => '业务员ID', 'limit' => 11, 'default' => 0])
            ->addColumn('store_id', 'integer', ['comment' => '门店ID', 'limit' => 11, 'default' => 0])
            ->addColumn('settlement_type', 'integer', ['comment' => '结算方式:1现金 2微信 3支付宝 4银行卡 5余额 6预付款 7挂账', 'limit' => 11, 'default' => 0])
            ->addColumn('settlement_cycle', 'integer', ['comment' => '结算周期:1日结 2周结 3月结 4季结 5半年结 6年结', 'limit' => 11, 'default' => 0])
            ->addColumn('balance', 'decimal', ['comment' => '余额', 'precision' => 10, 'scale' => 2, 'default' => 0.00])
            ->addIndex(['company_id', 'salesman_id', 'store_id'], ['name' => 'idx_company_salesman_store'])
            ->create();
    }
}
